const postcss = require('postcss');

// 自定义 将 px 转换为 rem 的插件
const plugin = (options) => {

    const pxReg = /(\d+)/ig;
    return {
        postcssPlugin:'postcss-simple-px2rem',
        declaration(decl) {
            decl.value = decl.value.replace(pxReg,(matchStr,num) => {
                    return num / options.base + 'rem';
                })
        }
    }

}

// base 设置 1rem = 75 px
postcss([plugin({
    base:75
})])
    .process('a{font-size:20px;')
    .then(res =>{
        console.log(res.css);
    });


